﻿using System;
using System.Collections.Generic;
using System.Text;
using SIMA.Core.Data.Entity;
using System.ComponentModel;
using System.Threading;

namespace SIMA.Core.Security
{
    public static class XmlArchiveQueue
    {
        static Queue<XmlEntity> queue;
        static BackgroundWorker backgroundWorker;

        //public XmlArchiveQueue()
        //{
            
        //}

        private static void Init()
        {
            queue = new Queue<XmlEntity>();
            backgroundWorker = new BackgroundWorker();
            backgroundWorker.WorkerReportsProgress = true;
            backgroundWorker.DoWork += new DoWorkEventHandler(backgroundWorker_DoWork);
            backgroundWorker.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker_ProgressChanged);
            backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker_RunWorkerCompleted);
        }

        static void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            
        }

        static void backgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            
        }

        static void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            string xmlString = string.Empty;
            Thread.Sleep(1000);
            xmlString=queue.Dequeue().ToXml();
            e.Result = xmlString;
            
        }



    }
}
